const fs = require('fs');
const http = require('http')
http.createServer((request, response) => {
    const { url, method } = request
    if (url === '/' && method === 'GET') {
        fs.readFile('read.text', (err, data) => {
            if (err) {
                response.writeHead(500, {
                    'Content-Type': ''
                })
                response.end('500 服务器挂了')
                return
            }
            response.statusCode = 200
            response.setHeader('Content-Type', '')
            response.end(data)
        })
    } else {
        response.statusCode = 404
        response.setHeader('')
    }
}).listen(3000, () => {
    console.log('Server at 3000');
})




